<?php
require_once("../../utils/resolve_json.php");
$key = "cg_name";
$value = null;
if (isset($data['name'])) {
    $value = $data['name'];
}
$table_name = "categories";
$no_auto_echo = true;

require("../../utils/pagination.php");

/* 对第一次查询的数据进行了处理 后再返回 */
$new_arr = array_map(function ($item) {
    $uuid = $item['cg_uuid'];
    SQLTools::rowTB($GLOBALS['conn'], "categories");
    if (SQLTools::rowTB($GLOBALS['conn'], "categories", "cg_pid='$uuid'")  > 0) {
        $item['hasChildren'] =  true;
    } else {
        $item['hasChildren'] =  false;
    }
    return $item;
}, $query_result["data"]);
$query_result["data"] = $new_arr;
